package com.cn.web.dao;

import com.cn.web.entity.PmsProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 商品信息(PmsProduct)表数据库访问层
 *
 * @author makejava
 * @since 2020-08-31 11:43:37
 */
@Mapper
public interface PmsProductDao {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Select("  select\n" +
            "          id, brand_id, product_category_id, feight_template_id, product_attribute_category_id, name, " +
            "pic, product_sn, delete_status, publish_status, new_status, recommand_status, verify_status, sort, sale," +
            " price, promotion_price, gift_growth, gift_point, use_point_limit, sub_title, description, " +
            "original_price, stock, low_stock, unit, weight, preview_status, service_ids, keywords, note, album_pics," +
            " detail_title, detail_desc, detail_html, detail_mobile_html, promotion_start_time, promotion_end_time, " +
            "promotion_per_limit, promotion_type, brand_name, product_category_name\n" +
            "        from mall2.pms_product\n" +
            "        where id = #{id}")
    PmsProduct queryById(Long id);

    /**
     * 修改数据
     *
     * @param pmsProduct 实例对象
     * @return 影响行数
     */
    int update(PmsProduct pmsProduct);
    /**
     *  查询数据
     * @param offset
     * @param limit
     * @return
     */
    @Select("select * from pms_product  limit #{offset},#{limit}")
    List<PmsProduct> queryAllByLimit(
            @Param("offset")Integer offset, @Param("limit")Integer limit);

    /**
     * 查询记录条数
     * @return
     */
    @Select("select count(*) from pms_product")
    int queryTotal();
}
